From: Morgan Date: Wed, 25 Jun 2025 12:52:02 +0000 (+0900) Subject: powerProfiles: Handle error if profile does not exists X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~124^2^2~22 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=a15affa9d600517ff95895f5da3b4515167ac2a1;p=gnome-shell.git powerProfiles: Handle error if profile does not exists Part-of: --- diff --git a/js/ui/status/powerProfiles.js b/js/ui/status/powerProfiles.js index 21680207d..3145c2375 100644 --- a/js/ui/status/powerProfiles.js +++ b/js/ui/status/powerProfiles.js @@ -31,6 +31,11 @@ const PROFILE_PARAMS = { }, }; +const FALLBACK_PARAMS = { + name: C_('Power profile', 'Custom'), + iconName: 'gnome-power-manager-symbolic', +}; + const LAST_PROFILE_KEY = 'last-selected-power-profile'; const PowerProfilesToggle = GObject.registerClass( @@ -82,6 +87,9 @@ class PowerProfilesToggle extends QuickMenuToggle { .map(p => p.Profile.unpack()) .reverse(); for (const profile of profiles) { + if (!PROFILE_PARAMS[profile]) + continue; + const {name, iconName} = PROFILE_PARAMS[profile]; if (!name) continue; @@ -110,7 +118,7 @@ class PowerProfilesToggle extends QuickMenuToggle { : PopupMenu.Ornament.NONE); } - const {name: subtitle, iconName} = PROFILE_PARAMS[activeProfile]; + const {name: subtitle, iconName} = PROFILE_PARAMS[activeProfile] ?? FALLBACK_PARAMS; this.set({subtitle, iconName}); this.checked = activeProfile !== 'balanced';